{include file="public/head"}
<style>
    .driver .layui-anim-upbit{z-index: 1000;}
    /*.cityDel{position: absolute;right: -5px;top: -5px;font-size: 5px;color: #0C0C0C;}*/
</style>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a>
              <cite>公共管理</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">版权所有</label>
                            <div class="layui-input-inline">
                                <input type="text" name="company" required  lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{$data.company}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">公司名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" required  lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{$data.name}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式</label>
                            <div class="layui-input-inline">
                                <input type="text" name="phone" required  lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{$data.phone}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">备案号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="number" required  lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{$data.number}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">技术支持</label>
                            <div class="layui-input-inline">
                                <input type="text" name="support" required  lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{$data.support}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>网站LOGO
                            </label>
                            <div class="layui-upload-drag image" id="image" style="width: 168px;">
                                {eq name="data.image" value=""}
                                <i class="layui-icon" style="font-size: 40px;">&#xe67c;</i>
                                <p>点击上传</p>
                                {else/}
                                <img src="{$data.image}" alt="..." style="width: 168px;height: 75px;">
                                <input type="hidden" name="image" value="{$data.image}">
                                {/eq}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>官方微信
                            </label>
                            <div class="layui-upload-drag image" id="img" style="width: 168px;">
                                {eq name="data.img" value=""}
                                <i class="layui-icon" style="font-size: 40px;">&#xe67c;</i>
                                <p>点击上传</p>
                                {else/}
                                <img src="{$data.img}" alt="..." style="width: 168px;height: 75px;">
                                <input type="hidden" name="img" value="{$data.img}">
                                {/eq}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>广告图
                            </label>
                            <div class="layui-upload-drag image" id="imgs" style="width: 168px;">
                                {eq name="data.img" value=""}
                                <i class="layui-icon" style="font-size: 40px;">&#xe67c;</i>
                                <p>点击上传</p>
                                {else/}
                                <img src="{$data.imgs}" alt="..." style="width: 168px;height: 75px;">
                                <input type="hidden" name="imgs" value="{$data.imgs}">
                                {/eq}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">广告图链接</label>
                            <div class="layui-input-inline">
                                <input type="text" name="url" required
                                       autocomplete="off" class="layui-input" value="{$data.url}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="add">立即保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['table','form','upload'], function(){
        var table = layui.table
            ,upload = layui.upload
            ,form = layui.form;
        upload.render({
            elem: '#image'
            ,url: '{:url("Lunbo/LunboImage")}'
            ,done: function(res){
                if (res.code !== 1){
                    layer.msg(res.msg, {icon: 5,time:1000},function () {
                        return false;
                    });
                }
                let dome = '<img src="'+ res.url +'" alt="..." style="width: 168px;height: 75px;">\n' +
                    '<input type="hidden" name="image" value="'+ res.url +'">';
                $('#image').children().remove();
                $('#image').append(dome);
                form.render();
            }
        });
        upload.render({
            elem: '#img'
            ,url: '{:url("Lunbo/LunboImage")}'
            ,done: function(res){
                if (res.code !== 1){
                    layer.msg(res.msg, {icon: 5,time:1000},function () {
                        return false;
                    });
                }
                let dome = '<img src="'+ res.url +'" alt="..." style="width: 168px;height: 75px;">\n' +
                    '<input type="hidden" name="img" value="'+ res.url +'">';
                $('#img').children().remove();
                $('#img').append(dome);
                form.render();
            }
        });
        upload.render({
            elem: '#imgs'
            ,url: '{:url("Lunbo/LunboImage")}'
            ,done: function(res){
                if (res.code !== 1){
                    layer.msg(res.msg, {icon: 5,time:1000},function () {
                        return false;
                    });
                }
                let dome = '<img src="'+ res.url +'" alt="..." style="width: 168px;height: 75px;">\n' +
                    '<input type="hidden" name="imgs" value="'+ res.url +'">';
                $('#imgs').children().remove();
                $('#imgs').append(dome);
                form.render();
            }
        });
        //监听提交
        form.on('submit(add)',function(data) {
            //发异步，把数据提交给php
            $.post('{:url("save")}', data.field, function (res) {
                if (res.code == 1){
                    layer.msg(res.msg, {icon: 6,time:1000});
                }else {
                    layer.msg(res.msg, {icon: 5,time:1500});
                }
            });
            return false;
        });
    });
</script>
</html>